import os
import copy

BIN_DIR=os.environ['BIN_DIR'];
LIB_DIR=os.environ['LIB_DIR'];

MTFS_SOURCES = [
  'fs_mt.c'
]
env=DefaultEnvironment().Clone()
env.Library(os.path.join(LIB_DIR, 'mt'), MTFS_SOURCES, LIBS=[])

FSTEST_SOURCES = [
  'fs_test.c'
]
env=DefaultEnvironment().Clone()
env.Library(os.path.join(LIB_DIR, 'fstest'), FSTEST_SOURCES, LIBS=[])

FATFS_SOURCES = [
  'fs_os_fatfs.c',
  'fatfs/ff/ff.c',
  'fatfs/diskio_ramdisk.c',
  'fatfs/ff/ffunicode.c'
]

env=DefaultEnvironment().Clone()
env.Library(os.path.join(LIB_DIR, 'fatfs'), FATFS_SOURCES, LIBS=[])

LIBS=['fatfs', 'mt', 'fstest'] + env['LIBS']
env.Program(os.path.join(BIN_DIR, 'fatfs_test'), ['fatfs_test.c'], LIBS=LIBS);

SPIFFS_SOURCES = [
 'fs_os_spiffs.c',
  Glob('spiffs/*.c')
]

env=DefaultEnvironment().Clone()
env.Library(os.path.join(LIB_DIR, 'spiffs'), SPIFFS_SOURCES, LIBS=[])

LIBS=['spiffs', 'mt', 'fstest'] + env['LIBS']
env.Program(os.path.join(BIN_DIR, 'spiffs_test'), ['spiffs_test.c'], LIBS=LIBS);

POSIX_SOURCES = [
  'fs_os_posix.c'
]

env=DefaultEnvironment().Clone()
env.Library(os.path.join(LIB_DIR, 'posix'), POSIX_SOURCES, LIBS=[])

LIBS=['posix', 'mt', 'fstest'] + env['LIBS']
env.Program(os.path.join(BIN_DIR, 'posix_test'), ['posix_test.c'], LIBS=LIBS);
